using System;
using System.Collections.Generic;
using System.IO;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Messaging;
using System.Text;
using Universe.Remoting.Sinks;

namespace Universe.Remoting.Extensions
{
    class TransparentDeliveryClientSink : BaseCustomSink
    {
        protected override void ProcessRequest(IMessage message, ITransportHeaders headers, ref Stream stream, ref object state)
        {
            
            DeliveryDictionary dict = new DeliveryDictionary();
            TransparentDeliveryConfiguration.OnClient(dict);

            ContextData data = ContextData.Serialize(dict);

            IMethodMessage mm = message as IMethodMessage;
            if (mm != null)
            {
                mm.LogicalCallContext.SetData(
                    ContextData.SlotName,
                    data.Keys.Length > 0 ? data : null
                    );
            }

        }
    }
}
